<admintpl file="header"/>
</head>
<style>
	.btn{margin-left:20px;}
</style>
<body class="J_scroll_fixed">
<div class="wrap J_check_wrap fx_pr">
<h3>{$res.name}</h3>
		<form action="{:U('Lottery/adds_post')}" method="post" class="form-horizontal js-ajax-forms" id="form">
		<input type="hidden" name="lottery_class_id" value="{$res.id}">
		<input type="hidden" name="p" value="{$p}">
		<div class="control-group">
			<label class="control-label">期号：</label>
			<div class="controls">
				<input type="text" name="qihao" id="qihao">&nbsp;&nbsp;
				<span id="qi"></span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">开奖码：</label>
			<div class="controls">
				<textarea style="width: 250px;height: 80px;" id="cont" name="conts"></textarea>&nbsp;&nbsp;<span id="kai"></span>
			</div>
		</div>
		<div class="form-actions1" style="margin-left: 260px;">
			<button class="btn" type="button" onclick="sav()">保存</button>
			<button class="btn" type="button" onclick="javascript:history.back(-1);">返回</button>
		</div>
	</form>
	<script type="text/javascript">

	function sav(){
		var id = $('input[name="lottery_class_id"]').val()
        var qihao = $("#qihao").val();
		var pas = $("#cont").val().replace(/\s/g,"");
		if(qihao==""){
			$("#qi").html("<font color='red'>请选择期号</font>");
			return false;
		}
		$("#qi").html("");
		if(pas==""){
			$("#kai").html("<font color='red'>开奖码不能为空</font>");
			return false;
		}
		$("#kai").html("");
        $.ajax({
            type: "POST",
            url: "{:U('Lottery/is_qis')}",
            data: {id:id,qihao:qihao,pas:pas},
            success: function(dat){
                if(dat==1){
                    $("#qi").html("<font color='red'>该期号已设置了开奖码</font>");
					return false;
				}else{
					$("#qi").html("");
					$("#form").submit();
				}
            }
        });
	}
	</script>
</body>
</html>